const md5 = require("../../middleware/md5");
const {User} = require("../../model/user");
module.exports = async (req, res) => {
  const {email, password} = req.body;
  const users = await User.findOne({email});
  // 是否查找到邮箱用户
  if (users) {
    // 密码对比
    if (users.password === (await md5(password))) {
      res.send({msg: "true"});
    } else {
      res.status(400).send({msg: "密码不对!"});
    }
  } else {
    res.status(400).send({msg: "没有找到用户!"});
  }
};
